<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="cn">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" cmvn ontent="width=device-width, initial-scale=1">

    <title>超级无敌的APP商店| </title>

    <link href="${pageContext.request.contextPath}/css/bootstrap.min.css" rel="stylesheet">

    <link href="${pageContext.request.contextPath}/css/custom.min.css" rel="stylesheet">
    
    <script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
    <script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
    <style>
      #btn{
        height: 25px;
        padding: 0 5px;
      }
    </style>
  </head>

  <body class="nav-md">
    <div class="container body">
      <div class="main_container">
        <div class="col-md-3 left_col">
          <div class="left_col scroll-view">
            <div class="navbar nav_title" style="border: 0;">
              <a href="index.html" class="site_title"> <span>超级无敌的APP软件商店</span></a>
            </div>

            <div class="clearfix"></div>

            <!-- menu profile quick info -->
            <div class="profile">
              <div class="profile_pic">
                <img src="${pageContext.request.contextPath}/img/img.jpg" alt="..." class="img-circle profile_img">
              </div>
              <div class="profile_info">
                <span>Welcome,</span>
                <h2>刘大帅</h2>
              </div>
            </div>
            <!-- /menu profile quick info -->

            <br />

            <!-- sidebar menu -->
            <div id="sidebar-menu" class="main_menu_side hidden-print main_menu">
              <div class="menu_section">

                <ul class="nav side-menu">
                  <li>

                  </li>
                  <li><a><i class="fa fa-home"></i> APP客户管理 <span class="fa fa-chevron-down"></span></a>

                  </li>
                  <li><a><i class="fa fa-edit"></i> APP应用管理 <span class="fa fa-chevron-down"></span></a>
                  </li>
                </ul>
              </div>

            </div>
            <!-- /sidebar menu -->

            <!-- /menu footer buttons -->
            <div class="sidebar-footer hidden-small">
              <a data-toggle="tooltip" data-placement="top" title="Settings">
                <span class="glyphicon glyphicon-cog" aria-hidden="true"></span>
              </a>
              <a data-toggle="tooltip" data-placement="top" title="FullScreen">
                <span class="glyphicon glyphicon-fullscreen" aria-hidden="true"></span>
              </a>
              <a data-toggle="tooltip" data-placement="top" title="Lock">
                <span class="glyphicon glyphicon-eye-close" aria-hidden="true"></span>
              </a>
              <a data-toggle="tooltip" data-placement="top" title="Logout">
                <span class="glyphicon glyphicon-off" aria-hidden="true"></span>
              </a>
            </div>
            <!-- /menu footer buttons -->
          </div>
        </div>

        <!-- top navigation -->
        <div class="top_nav">
          <div class="nav_menu">
            <nav>
              <div class="nav toggle">
                <a id="menu_toggle"><i class="fa fa-bars"></i></a>
              </div>

              <ul class="nav navbar-nav navbar-right">
                <li class="">
                  <a href="javascript:;" class="user-profile dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                    <img src="${pageContext.request.contextPath}/img/img.jpg" alt="">刘大帅
                    <span class=" fa fa-angle-down"></span>
                  </a>
                  <ul class="dropdown-menu dropdown-usermenu pull-right">
                    <li><a href="javascript:;"> Profile</a></li>
                    <li>
                      <a href="javascript:;">
                        <span class="badge bg-red pull-right">50%</span>
                        <span>Settings</span>
                      </a>
                    </li>
                    <li><a href="javascript:;">Help</a></li>
                    <li><a href="login.html"><i class="fa fa-sign-out pull-right"></i> Log Out</a></li>
                  </ul>
                </li>

                <li role="presentation" class="dropdown">
                  <a href="javascript:;" class="dropdown-toggle info-number" data-toggle="dropdown" aria-expanded="false">
                    <i class="fa fa-envelope-o"></i>
                    <span class="badge bg-green">6</span>
                  </a>
                  <ul id="menu1" class="dropdown-menu list-unstyled msg_list" role="menu">
                    <li>
                      <a>
                        <span class="image"><img src="" alt="Profile Image" /></span>
                        <span>
                          <span>John Smith</span>
                          <span class="time">3 mins ago</span>
                        </span>
                        <span class="message">
                          Film festivals used to be do-or-die moments for movie makers. They were where...
                        </span>
                      </a>
                    </li>
                    <li>
                      <a>
                        <span class="image"><img src="${pageContext.request.contextPath}/img/img.jpg" alt="Profile Image" /></span>
                        <span>
                          <span>John Smith</span>
                          <span class="time">3 mins ago</span>
                        </span>
                        <span class="message">
                          Film festivals used to be do-or-die moments for movie makers. They were where...
                        </span>
                      </a>
                    </li>
                    <li>
                      <a>
                        <span class="image"><img src="${pageContext.request.contextPath}/img/img.jpg" alt="Profile Image" /></span>
                        <span>
                          <span>John Smith</span>
                          <span class="time">3 mins ago</span>
                        </span>
                        <span class="message">
                          Film festivals used to be do-or-die moments for movie makers. They were where...
                        </span>
                      </a>
                    </li>
                    <li>
                      <a>
                        <span class="image"><img src="${pageContext.request.contextPath}/img/img.jpg" alt="Profile Image" /></span>
                        <span>
                          <span>John Smith</span>
                          <span class="time">3 mins ago</span>
                        </span>
                        <span class="message">
                          Film festivals used to be do-or-die moments for movie makers. They were where...
                        </span>
                      </a>
                    </li>
                    <li>
                      <div class="text-center">
                        <a>
                          <strong>See All Alerts</strong>
                          <i class="fa fa-angle-right"></i>
                        </a>
                      </div>
                    </li>
                  </ul>
                </li>
              </ul>
            </nav>
          </div>
        </div>
        <!-- /top navigation -->


        <!-- page content -->
        <div class="right_col" role="main">

          <div class="row">
            <div class="col-md-12 col-sm-12 col-xs-12">
              <div class="x_panel">
                <div class="x_title">
                  <h2>请添加您的APP信息 <small>我们拭目以待您的超级无敌格拉斯作品</small></h2>

                  <div class="clearfix"></div>
                </div>
                <div class="x_content">

                  <form class="form-horizontal form-label-left" novalidate action="${pageContext.request.contextPath}/app_info/do_add_app" method="post" enctype="multipart/form-data">

                    <p><code>可以申请酬劳哦</code> 点击这里 <a href="form.html">申请费用</a>
                    </p>
                    <span class="section">软件信息</span>
                    <div class="item form-group">
                      <label class="control-label col-md-3 col-sm-3 col-xs-12" for="softName">软件名 <span class="required">*</span>
                      </label>
                      <div class="col-md-6 col-sm-6 col-xs-12">
                        <input id="softName" class="form-control col-md-7 col-xs-12" data-validate-length-range="6" data-validate-words="2" name="softwareName" placeholder="填写您的软件名" required="required" type="text">
                      </div>

                    </div>

                    <div class="item form-group">
                      <label class="control-label col-md-3 col-sm-3 col-xs-12" for="APKName">文件名 <span class="required">*</span>
                      </label>
                      <div class="col-md-6 col-sm-6 col-xs-12">
                        <input id="APKName" class="form-control col-md-7 col-xs-12" data-validate-length-range="6" data-validate-words="2" name="APKName" placeholder="com.christopher.shuai" required="required" type="text">
                      </div>
                      <span id="msg">检查文件名</span>
                    </div>
                    <div class="item form-group">
                      <label class="control-label col-md-3 col-sm-3 col-xs-12" for="supportROM">支持的系统 <span class="required">*</span>
                      </label>
                      <div class="col-md-6 col-sm-6 col-xs-12">
                        <select class="form-control has-feedback-left" name="supportROM" id="supportROM">
                          <option value="">----------请选择----------</option>
                          <option value="Android 8.0">Android 8.0</option>
                          <option value="鸿蒙 2.0">鸿蒙 2.0</option>
                          <option value="IOS 120">IOS 12</option>
                        </select>
                      </div>
                    </div>
                    <div class="item form-group">
                      <label class="control-label col-md-3 col-sm-3 col-xs-12" for="interfaceLanguage">软件语言<span class="required">*</span>
                      </label>
                      <div class="col-md-6 col-sm-6 col-xs-12">
                        <select class="form-control has-feedback-left"  id="interfaceLanguage" name = "interfaceLanguage" >
                          <option value="">----------请选择----------</option>
                          <option value="中国话">中国话</option>
                          <option value="外国话">外国话</option>
                          <option value="未知">未知</option>
                        </select>
                      </div>
                    </div>
                    <div class="item form-group">
                      <label class="control-label col-md-3 col-sm-3 col-xs-12" for="platformId">所属平台 <span class="required">*</span>
                      </label>
                      <div class="col-md-6 col-sm-6 col-xs-12">
                        <select id = "platformId" class="form-control has-feedback-left" name="platformId" id="platformId">
                          <option value="">----------请选择----------</option>
                          <c:forEach items="${appPlatforms}" var="platform">
                            <option value="${platform.valueId}">${platform.valueName}</option>
                          </c:forEach>
                        </select>
                      </div>
                    </div>
                    <div class="item form-group">
                      <label class="control-label col-md-3 col-sm-3 col-xs-12" for="catagoryLevel1">一级分类 <span class="required">*</span>
                      </label>
                      <div class="col-md-6 col-sm-6 col-xs-12">
                        <select class="form-control has-feedback-left" name="categoryId1" id="catagoryLevel1">
                          <option value="">----------请选择-----------</option>
                          <c:forEach items="${appCategoryies}" var="appCategory">
                            <option value="${appCategory.id}">${appCategory.categoryName}</option>
                          </c:forEach>
                        </select>
                      </div>
                    </div>
                    <div class="item form-group">
                      <label class="control-label col-md-3 col-sm-3 col-xs-12" for="catagoryLevel2">二级分类 <span class="required">*</span>
                      </label>
                      <div class="col-md-6 col-sm-6 col-xs-12">
                        <select class="form-control has-feedback-left" name="categoryId2" id="catagoryLevel2">
                          <option value="">----------请选择-----------</option>
                        </select>
                      </div>
                    </div>
                    <div class="item form-group">
                      <label class="control-label col-md-3 col-sm-3 col-xs-12" for="catagoryLevel3">三级分类 <span class="required">*</span>
                      </label>
                      <div class="col-md-6 col-sm-6 col-xs-12">
                        <select class="form-control has-feedback-left" name="categoryId3" id="catagoryLevel3">
                          <option value="">----------请选择-----------</option>
                        </select>
                      </div>
                    </div>
                    <div class="item form-group">
                      <label for="appInfo" class="control-label col-md-3 col-sm-3 col-xs-12">软件简介</label>
                      <div class="col-md-6 col-sm-6 col-xs-12">
                        <textarea id="appInfo" class="form-control has-feedback-left"  name="appInfo"></textarea>
                      </div>
                    </div>
                    <div class="item form-group">
                      <label class="control-label col-md-3 col-sm-3 col-xs-12" for="upload">上传Logo图片 <span class="required">*</span>
                      </label>
                      <div class="col-md-6 col-sm-6 col-xs-12">
                        <input type="file" id="upload" name="upload" required="required" data-validate-length-range="8,20" class="form-control col-md-7 col-xs-12">
                      </div>
                    </div>
                    <div class="ln_solid"></div>
                    <div class="form-group">
                      <div class="col-md-6 col-md-offset-3">
<%--                        <button type="submit" class="btn btn-primary">Cancel</button>--%>
                        <input id="send" type="submit" class="btn btn-success" value="提交"/>
                      </div>
                    </div>
                  </form>
                </div>
              </div>
            </div>



          </div>

          <div class="row">


          </div>

        </div>

        <footer>
          <div class="pull-right">
            APP管理系统 <a href="https://www.kgc.cn">北大青鸟课工场</a>
          </div>
          <div class="clearfix"></div>
        </footer>
        <!-- /footer content -->
      </div>
    </div>
      <script>
        $("#APKName").blur(function () {
          let apkName = $(this).val();
          if (apkName == null && apkName == ""){
            $("#msg").html("您需要填写文件名");
          }
          //alert(apkName);
          let queryApkUser = "${pageContext.request.contextPath}/app_info/query_apk";

          $.ajax({
            //设置参数的格式
            contentType:"application/json",
            url:queryApkUser,
            //ajax传递参数的方式
            data:apkName,
            type:"post",
            success:function (data) {
              $("#msg").html(data.msgString);
              // if(data == 0){
              //   $("#msg").html("文件名可以使用")
              // }else {
              //   $("#msg").html("文件名非法")
              // }
            },
            // error:function (data) {
            //   $("#msg").html(data.msgString);
            // }
          })

        })


        $("#catagoryLevel1").change(function () {
          let url = "${pageContext.request.contextPath}/app_category/query_category/"+$(this).val();

          //alert(url)
          let option = "<option value=''>-----请选择-----</option>"
          $("#catagoryLevel3").html(option);
          $.ajax({
            url:url,
            data_type:"json",
            success:function (data) {
              // console.log(data)
              for (let i=0;i<data.length;i++){
                option += "<option value="+data[i].id+">"+data[i].categoryName+"</option>"
              }

              $("#catagoryLevel2").html(option)
            }
          })
        })

        $("#catagoryLevel2").change(function () {
          // alert($(this).val())
          let url = "${pageContext.request.contextPath}/app_category/query_category/"+$(this).val();
          //alert(url)
          let option = "<option value=''>-----请选择-----</option>"
          $.ajax({
            url:url,
            data_type:"json",
            success:function (data) {

              for (let i=0;i<data.length;i++){
                option += "<option value="+data[i].id+">"+data[i].categoryName+"</option>"
              }

              $("#catagoryLevel3").html(option);

            }
          })
        })


      </script>
  </body>
</html>
